package com.finer.controller.warehouse;

import com.finer.dto.warehouse.WarehouseInfoPageDTO;
import com.finer.entity.ResponseMessage;
import com.finer.entity.stock.FinerWarehouse;
import com.finer.remote.warehouse.FinerWarehouseRemote;
import com.finer.service.warehouse.WarehouseInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangenhao
 * @className WarehouseInfoController
 * @description 仓库信息请求控制层
 * @date 2024-10-23 下午5:09
 **/
@RestController
@RequestMapping("/warehouseInfo")
@Slf4j
public class WarehouseInfoController implements FinerWarehouseRemote {

    @Autowired
    private WarehouseInfoService warehouseInfoService;

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 查询仓库信息分页
     * @date 2024/10/23 下午5:20
     * @Param warehouseInfoPageDTO:
     **/
    @GetMapping("/page")
    public ResponseMessage getWarehouseInfoPage(WarehouseInfoPageDTO warehouseInfoPageDTO) {
        log.info("WarehouseInfoController getWarehouseInfoPage warehouseInfoPageDTO:{}", warehouseInfoPageDTO);
        ResponseMessage rs = warehouseInfoService.getWarehouseInfoPage(warehouseInfoPageDTO);
        log.info("WarehouseInfoController getWarehouseInfoPage warehouseInfoPageDTO:{} rs:{}", warehouseInfoPageDTO, rs);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 新增仓库信息
     * @date 2024/10/23 下午5:20
     * @Param finerWarehouse:
     **/
    @PostMapping("/add")
    public ResponseMessage addWarehouseInfo(@RequestBody FinerWarehouse finerWarehouse) {
        log.info("WarehouseInfoController addWarehouseInfo finerWarehouse:{}", finerWarehouse);
        ResponseMessage rs = warehouseInfoService.addWarehouseInfo(finerWarehouse);
        log.info("WarehouseInfoController addWarehouseInfo finerWarehouse:{} rs:{}", finerWarehouse, rs);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 根据id查询仓库信息
     * @date 2024/10/23 下午5:21
     * @Param id:
     **/
    @GetMapping("/{id}")
    public ResponseMessage getWarehouseInfoById(Integer id) {
        log.info("WarehouseInfoController getWarehouseInfoById id:{}", id);
        ResponseMessage rs = warehouseInfoService.getWarehouseInfoById(id);
        log.info("WarehouseInfoController getWarehouseInfoById id:{} rs:{}", id, rs);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 校验仓库编码是否存在
     * @date 2024/10/23 下午5:21
     * @Param houseCode:
     **/
    @GetMapping("/checkHouseCode")
    public ResponseMessage checkHouseCode(String houseCode) {
        log.info("WarehouseInfoController checkHouseCode houseCode:{}", houseCode);
        ResponseMessage rs = warehouseInfoService.checkHouseCode(houseCode);
        log.info("WarehouseInfoController checkHouseCode houseCode:{} rs:{}", houseCode, rs);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 修改仓库信息
     * @date 2024/10/23 下午5:22
     * @Param finerWarehouse:
     **/
    @PutMapping("/update")
    public ResponseMessage updateWarehouseInfo(FinerWarehouse finerWarehouse) {
        log.info("WarehouseInfoController updateWarehouseInfo finerWarehouse:{}", finerWarehouse);
        ResponseMessage rs = warehouseInfoService.updateWarehouseInfo(finerWarehouse);
        log.info("WarehouseInfoController updateWarehouseInfo finerWarehouse:{} rs:{}", finerWarehouse, rs);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 删除仓库信息
     * @date 2024/10/23 下午5:22
     * @Param id:
     **/
    @DeleteMapping("/delete")
    public ResponseMessage deleteWarehouseInfo(Integer id) {
        log.info("WarehouseInfoController deleteWarehouseInfo id:{}", id);
        ResponseMessage rs = warehouseInfoService.deleteWarehouseInfo(id);
        log.info("WarehouseInfoController deleteWarehouseInfo id:{} rs:{}", id, rs);
        return rs;
    }
}
